import java.io.StringWriter;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;


public class RefreshManager {
	
	Element name;
	Element status;
	
	
	
	public RefreshManager() {
		
		
		name = (Element)(status.getElementsByTagName("name").item(0));
		

		System.out.println(name.getTextContent());
		String namestring = new String(name.getTextContent());
		
		
		
		
		Document tweetStream;
		
		
		NodeList nodeList;
		
		
		Element statuses;
		Element status;
		Element text;
		Element user;
		Element name;
		
		
		String[] keywords = {"monkey", "pie"};
		
		tweetStream = TweetGrabber.getTweetsByScreenName("valongolive");
		
		nodeList = tweetStream.getElementsByTagName("statuses");
		
	
		statuses = (Element)(nodeList.item(0));
		
		
		nodeList = statuses.getElementsByTagName("status");
		
		for (int n=0; n < nodeList.getLength(); ++n) {
			
			status = (Element)(nodeList.item(n));
			
			
			text = (Element)(status.getElementsByTagName("text").item(0));
			
			
			
			user = (Element)(status.getElementsByTagName("user").item(0));
			
			name = (Element)(status.getElementsByTagName("name").item(0));
			

	
			String namestring = new String(name.getTextContent());		
			
		}
					
		
	}


	
	private static void showXML(Document d) {
		
		Transformer transformer = null;
		
		DOMSource domSource=new DOMSource(d);
	    
	    StringWriter stringWriter = new StringWriter();
	    StreamResult result       = new StreamResult(stringWriter);
	    
	    
	    
	    try {
	
	    	transformer = TransformerFactory.newInstance().newTransformer();
	        transformer.setOutputProperty("indent","yes");
	    
	    } catch (TransformerConfigurationException t) {
	
	    	System.out.println("Document is not well formed.");
	    	System.out.println("   " + t.getMessage());        	
	    
	    }
	
	   
	    try {
	
	    	transformer.transform(domSource, result);        
	    
	    } catch (TransformerException t) {
			System.out.println("Error converting document to string.");
	    	System.out.println("   " + t.getMessage());        	
	    	
	    }
	    System.out.println(stringWriter.toString());
		
	}

}
